import axios from "axios"
import { Indicator } from 'mint-ui';
import { Toast } from 'mint-ui';

//创建一个axios实例
var ajax = axios.create({
    baseURL: 'http://148.70.25.70:8080/app/mock/17'
});

//添加一个请求拦截器
ajax.interceptors.request.use(res => {
    Indicator.open({
        text: 'loading...',
        spinnerType: 'fading-circle'
    });
    return res
});

//添加一个响应拦截器
ajax.interceptors.response.use(res => {
    Indicator.close();
    if (res.data.res_code === 1) return res.data.res_body;
    else Toast({
        message: '提示:数据请求异常',
        position: 'bottom',
        duration: 2000
    });
    return res
});

//请求页面的轮播图数据
export var getHomeswiper = () => {
    return ajax.get('/api/swiperimgs');
}